#include<bits/stdc++.h>
using namespace std;
#define MAXSIZE 10

typedef struct {
	char data[MAXSIZE];
	int front;
	int rear;
}SQueue;
void InitQueue(SQueue& Q) {//初始化队列
	Q.front = Q.rear = 0;
}
bool QueueEmpty(const SQueue& Q) {//判断队空
	return Q.front == Q.rear;
}
void EnQueue(SQueue& Q, char x) {//插入元素
	Q.rear = (Q.rear + 1) % MAXSIZE;
	Q.data[Q.rear] = x;
}
char DeQueue(SQueue& Q) {//删除元素
	if (QueueEmpty(Q)) {
		printf("队列已空! 出队失败!\n");
		return INT_MAX;
	}
	Q.front = (Q.front + 1) % MAXSIZE;
	char x = Q.data[Q.front];
	return x;
}
int QueueSize(const SQueue& Q) {//返回列队中元素个数
	return Q.rear >= Q.front ? Q.rear - Q.front : Q.rear - Q.front + MAXSIZE;
}
void clearQueue(SQueue & Q){//清空队列
	Q.front = 0;
	Q.rear = 0;
}

int main() {
	SQueue q;
	InitQueue(q);//初始化队列
	cout << "创建循环队列q" << endl;
	if (QueueEmpty(q)) { cout << "队列q为空" << endl; }
	else { cout << "队列q不为空" << endl; }
	EnQueue(q, 'a');
	EnQueue(q, 'b');
	EnQueue(q, 'c');
	cout << "插入元素a，b，c" << endl;
	cout << "出队一个元素，该元素为：" << DeQueue(q) << endl;
	EnQueue(q, 'd');
	EnQueue(q, 'e');
	EnQueue(q, 'f');
	cout << "插入元素d，e，f" << endl;
	cout << "当前队列元素为：";
	while(!QueueEmpty(q)){
		cout << DeQueue(q) << " ";
	}
	clearQueue(q);
	return 0;
}